package com.vidmt.api.modules.sys.api;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.vidmt.api.common.pojo.ApiResultServer;
import com.vidmt.api.common.web.ApiController;
import com.vidmt.api.modules.sys.entity.Role;
import com.vidmt.api.modules.sys.entity.sub.RoleLvl;
import com.vidmt.api.modules.sys.service.RoleService;

@Controller
@RequestMapping("/api/1/public/role")
public class ApiRoleController extends ApiController{
	@Autowired
	private RoleService roleService;

	@ResponseBody
	@RequestMapping("/listlvls.*")
	public ApiResultServer getLvls() {
		List<Role> lvls = roleService.findClientRoleList();
		List<RoleLvl> rolelvl=new ArrayList<>(lvls.size());
		
		for(Role role:lvls){
			rolelvl.add(new RoleLvl(role));
		}
		return new ApiResultServer(rolelvl);
	}
}
